<template>
  <div id="content" style="overflow-y: scroll;height: 100vh">
    <span v-for="item in datas" v-html="item"></span>
  </div>
</template>

<script>
const {BrowserWindow} = require('electron')
export default {
  name: "ServerLogs",
  data: function() {
    return {
      type: null,
      serverId: null,
      host: '',
      datas: []
    }
  },
  methods: {
    getSocketResult(data) {
      let div = document.getElementById('content')
      // div.append(data)
      this.datas.push(data)
      div.scrollTo(0, div.scrollHeight)
    }
  },
  created() {
    this.type = this.$router.currentRoute.query.command
    this.serverId = this.$router.currentRoute.query.serverId
    this.host = this.$router.currentRoute.query.host
    let typeName = ""
    if (this.type == 1) {
      typeName = '主线日志'
    } else if (this.type == 2) {
      typeName = 'OpenApi日志'
    }
    document.title = typeName + ' ' + this.host
    this.socketApi.sendSock('/websocket/serverLog/'+this.serverId+'/'+this.type, null, this.getSocketResult)
  },
  mounted() {
  }
}
</script>

<style lang="scss" scoped>

</style>
